// 引入路由组件

// import Home from "@/views/Home";
// import Search from "@/views/Search"; 
import Login from "@/views/Login";
import Register from "@/views/Register";
import Detail from "@/views/Detail";
import AddCartSuccess from "@/views/AddCartSuccess";
import ShopCart from "@/views/ShopCart";
import Trade from "@/views/Trade";
import Pay from "@/views/Pay";
// import PaySuccess from "@/views/PaySuccess";
import Center from "@/views/Center";

// 引入二级路由
import Myorder from "@/views/Center/myOrder";
import GroupOrder from "@/views/Center/groupOrder";





export default [
  {
    path: "/paySuccess",
    // 路由懒加载
    component: ()=>import('@/views/PaySuccess'),
    meta: { isFooter: true },
  },
  {
    path: "/center",
    component: Center,
    meta: { isFooter: true },
    children: [
      {
        path: "myorder",
        component: Myorder,
      },
      {
        path: "grouporder",
        component: GroupOrder,
      },
      {
        path: "/center",
        redirect: "/center/myorder",
      },
    ],
  },
  {
    path: "/trader",
    component: Trade,
    meta: { isFooter: true },
    // 路由独享守卫
    beforeEnter: (to, from, next) => {
      if (from.path == "/shopcart") {
        next();
      } else {
        next(false);
      }
    },
  },
  {
    path: "/pay",
    component: Pay,
    meta: { isFooter: true },
    beforeEnter: (to, from, next) => {
      if (from.path == "/trader") {
        next();
      } else {
        next(false);
      }
    },
  },
  {
    path: "/detail/:skuid",
    component: Detail,
    meta: { isFooter: true },
  },
  {
    path: "/home",
    // 路由懒加载
    component: ()=>import("@/views/Home"),
    meta: { isFooter: true },
  },
  {
    path: "/ShopCart",
    component: ShopCart,
    meta: { isFooter: true },
  },

  {
    path: "/addcartsuccess",
    component: AddCartSuccess,
    meta: { isFooter: true },
    name: "addcartsuccess",
  },

  {
    path: "/search/:keyword?",
    // 路由懒加载
    component: ()=>import('@/views/Search'),
    name: "search",
    meta: { isFooter: true },
    // 路由组件能不能传递props数据
    //布尔值写法：params
    // props:true,
    // 对象写法:额外给路由传递一些props
    /* props:{
                a:1,
                b:2
            } */
    // 函数写法推荐  可以传递params参数，query参数，通过props传递给组件
    /* props: ($route) => {
        return {
          keyword: $route.params.keyword,
        };
      }, */
  },
  {
    path: "/login",
    component: Login,
    meta: { isFooter: false },
  },
  {
    path: "/register",
    component: Register,
    meta: { isFooter: false },
  },

  // 项目重定向
  {
    path: "*",
    redirect: "/home",
  },
];
